package com.google.code.kjug.guava.app;

import com.google.code.kjug.guava.app.data.OurDatabaseFakeout;
import com.google.common.collect.Multimap;
import org.hamcrest.collection.IsIterableContainingInOrder;
import org.junit.Ignore;
import org.junit.Test;

import java.util.Collection;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;

public class GuavaSweetness_UT {

    @Test
    @Ignore
    public void searchEngineShouldBeAbleToFindYouAClunker() {
        SearchEngine searchEngine = new SearchEngine();
        searchEngine.setDatabase(new OurDatabaseFakeout());

        Collection<String> cars = searchEngine.findMeAClunker();

        assertThat(cars, containsInAnyOrder(
                "1994 Honda Prelude ... runs great!",
                "1994 Honda Prelude ... runs great!",
                "1992 Jeep Cherokee"));
    }

    @Test
    @Ignore
    public void searchEngineShouldBeAbleToClassifyAllListings() {
        SearchEngine searchEngine = new SearchEngine();
        searchEngine.setDatabase(new OurDatabaseFakeout());

        Multimap<String, String> classifiedCars = searchEngine.classifyListings();

        assertThat(classifiedCars.get("awesome!"), containsInAnyOrder(
                "2011 Jeep Wrangler",
                "2009 BMW Z3"));
        assertThat(classifiedCars.get("nice"), containsInAnyOrder("2002 Honda Accord"));
        assertThat(classifiedCars.get("clunker"), containsInAnyOrder(
                "1992 Jeep Cherokee",
                "1994 Honda Prelude ... runs great!",
                "1994 Honda Prelude ... runs great!"));
    }
}
